//
//  CompletionView.m
//  Village
//
//  Created by 程虎 on 2017/9/24.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "CompletionView.h"

@implementation CompletionView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [Util colorWithHexString:@"#7b7b7b" alpha:0.7];
        [self set_UI];
    }
    return self;
}

- (void)set_UI
{
    UIImageView *bkimg = [UIImageView new];
    bkimg.image = [UIImage imageNamed:@"completion_bk"];
    bkimg.backgroundColor = KRedColors;
    bkimg.userInteractionEnabled = YES;
    [self addSubview:bkimg];
    
    UIButton *btn = [[Tools shareInstance] creat_Button:@"立即认证" Color:[UIColor whiteColor] BackColors:KRedColors Font:18 tag:300];
    UIButton *btn1 = [[Tools shareInstance] creat_Button:@"一会儿再说" Color:KRedColors BackColors:[UIColor whiteColor] Font:18 tag:301];
    [bkimg sd_addSubviews:@[btn,btn1]];
    
    [btn addTarget:self action:@selector(completionClickBlock:) forControlEvents:UIControlEventTouchUpInside];
    [btn1 addTarget:self action:@selector(completionClickBlock:) forControlEvents:UIControlEventTouchUpInside];
    LRViewRadius(btn, 5, 0.5, [UIColor clearColor]);
    
    bkimg.sd_layout
    .centerXEqualToView(self)
    .centerYEqualToView(self)
    .widthIs( 315 * AutoScaleX)
    .heightIs(400 * AutoScaleY);

    btn1.sd_layout
    .centerXEqualToView(bkimg)
    .bottomSpaceToView(bkimg, 25)
    .leftSpaceToView(bkimg, 90 * AutoScaleX)
    .rightSpaceToView(bkimg, 90 * AutoScaleX)
    .heightRatioToView(btn, 1)
    .heightIs(45);
    
    btn.sd_layout
    .centerXEqualToView(btn1)
    .bottomSpaceToView(btn1, 20)
    .leftEqualToView(btn1)
    .rightEqualToView(btn1)
    .heightRatioToView(btn1, 1);
}

- (void)completionClickBlock:(UIButton *)buttons
{
    if (buttons.tag == 300) {
        if (self.completionBlock) {
            self.completionBlock();
        }
    }
    [buttons.superview.superview removeFromSuperview];
}
@end
